home *** CD-ROM | disk | FTP | other *** search
/ DarkBASIC - The Ultimate 3D Game Creator / PCactive 8 CD1 - DarkBasic.iso / SOFTWARE / DEMOS / DarkForge2000 / snippets_vol1 / snip_rasters.dba < prev    next >
Encoding:
Text File  |  2000-08-05  |  1.5 KB  |  99 lines

  1. `    ------------------------------------------------------------------------
  2. `    Rasters Demonstration                       DarkForge Snippet (6/8/2000)
  3. `    ------------------------------------------------------------------------
  4. `
  5. `    Okay so they aren't real rasters - but they look good anyway! Includes
  6. `    my raster function for your own use.
  7.  
  8. sync rate 0
  9. sync on
  10. hide mouse
  11.  
  12. `    Call the raster function
  13. `    sprite #, starting colour, apply shades, height, step, multiplier
  14. `    (0 for 180, 45 for 90)
  15.  
  16. raster(1, 0,0,40, 0,0,1, 180, 2,0)
  17. raster(2, 0,40,0, 0,1,0, 180, 2,0)
  18.  
  19. cls 0 : y#=-195 : y2#=664
  20.  
  21. `    stars!
  22.  
  23. n=50
  24. dim x(n,3)
  25.  
  26. for i=1 to n
  27.     x(i,1)=rnd(639)+1
  28.     x(i,2)=rnd(479)+ 1
  29.     x(i,3)=rnd(9)+1
  30. next i
  31.  
  32. do
  33.  
  34.     cls 0
  35.  
  36.     sprite 1,0,y#,1
  37.     inc y#,4
  38.     if y#>660 then y#=-195
  39.  
  40.     sprite 2,0,y2#,2
  41.     dec y2#,4
  42.     if y2#<-195 then y2#=664
  43.  
  44.     for i=1 to n
  45.  
  46.         x(i,1)=x(i,1)-x(i,3)
  47.         
  48.         if x(i,1)<=1
  49.             x(i,1)=640
  50.             x(i,2)=rnd(479)+1
  51.         endif
  52.     
  53.         col=x(i,3)*30
  54.         ink rgb(col,col,col),1
  55.  
  56.         dot x(i,1),x(i,2)
  57.     
  58.     next i
  59.  
  60.     sync
  61.  
  62. loop
  63.  
  64.  
  65. ` Make my rasters
  66.  
  67. function raster(i,r,g,b,ro,go,bo,h,s,m)
  68.  
  69.     y=0
  70.     
  71.     repeat
  72.     
  73.         if ro=1 then rro=sin(y+m)*100
  74.         if go=1 then ggo=sin(y+m)*100
  75.         if bo=1 then bbo=sin(y+m)*100
  76.  
  77.         red=r+rro
  78.         if red>255 then red=255
  79.  
  80.         green=g+ggo
  81.         if green>255 then green=255
  82.  
  83.         blue=b+bbo
  84.         if blue>255 then blue=255
  85.  
  86.         ink rgb(red,green,blue),1
  87.  
  88.         line 0,y,640,y+1
  89.         inc y,s
  90.     
  91.     until y=h
  92.     
  93.     get image i,0,0,640,h
  94.     sprite i,0,-400,i
  95.     set sprite i,0,1
  96.  
  97. endfunction
  98.  
  99.